package com.bwie.controller;
import com.bwie.service.UserService;
import com.bwie.utils.R;
import com.bwie.vo.LoginVo;
import com.bwie.vo.PageInfoVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import org.springframework.beans.factory.annotation.Autowired;

import javax.annotation.PostConstruct;

/**
* 用户表(tb_user)表控制层
*
* @author xxxxx
*/
@RestController
@RequestMapping("/user/user")
public class UserController {
/**
* 服务对象
*/
    @Autowired
    private UserService userService;

    @ApiOperation("用户登录")
    @PostMapping("/login")
    public R login(@RequestBody @Validated LoginVo loginVo){
        return userService.login(loginVo);
    }

    @ApiOperation("菜单树")
    @PostMapping("/getMenuTree")
    public R getMenuTree(){
        return userService.getMenuTree();
    }


    @ApiOperation("分页获取商户信息")
    @PostMapping("/getUserList")
    public R getUserList(@RequestBody PageInfoVo pageInfoVo){
        return userService.getUserList(pageInfoVo);
    }

    @ApiOperation("获取当前登录用户的信息")
    @PostMapping("/getUserInfo")
    public R getUserInfo(){
        return userService.getUserInfo();
    }

    @ApiOperation("获取当前登录用户的信息222open")
    @PostMapping("/getUserInfoById/{userId}")
    public R getUserInfoById(@PathVariable Integer userId){
        return userService.getUserInfoById(userId);
    }

    @ApiOperation("用户签到")
    @PostMapping("/userSign")
    public R userSign(){
        return userService.userSign();
    }

    @ApiOperation("用户抽奖和积分")
    @PostMapping("/joinActiveSubScore/{userId}/{score}")
    public R joinActiveSubScore(@PathVariable("userId")Integer userId,@PathVariable("score")Integer score){
        return userService.joinActiveSubScore(userId,score);
    }


}
